package zz.note.thread.demo;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;
import java.util.Arrays;

/**
 * @Author: ZZ
 * @date 2022/2/16
 */
@Component
@Slf4j
public class AopLogManage {
	@Async
	public void requestLog(JoinPoint joinPoint, HttpServletRequest request) {
		// 接收到请求，记录请求内容

		// 记录下请求内容
		log.info("请求地址 : " + request.getRequestURL().toString());
		log.info("HTTP METHOD : " + request.getMethod());
		// 获取真实的ip地址
		//logger.info("IP : " + IPAddressUtil.getClientIpAddress(request));
		log.info("CLASS_METHOD : " + joinPoint.getSignature().getDeclaringTypeName() + "."
				+ joinPoint.getSignature().getName());
		log.info("参数 : " + Arrays.toString(joinPoint.getArgs()));
		//loggger.info("参数 : " + joinPoint.getArgs());
	}
}
